AROS

The Amiga Replacement OS


(C) 1996 AROS - The Amiga Replacement OS


Chapter 5. Developing Software for AROS

5.1 Setting up

To compile code for AROS, you only need the binary distribution and a C compiler. If you use Linux, you should have everything neccessary already, if you use Amiga, install the ADE development environment (see ADE).

5.2 Compiling

5.3 AROS extensions

AROS makes a few extensions to the original AmigaOS. Some of them are transparent and compatible, others are only compatible and some or not.

5.3.1 Macros

AROS defines a couple of macros in various header files. To enable them, you must define AROS_ALMOST_COMPATIBLE.

NEWLIST(list)
Compatible: Yes
Location: exec/lists.h

Initializes a list. You must not use any list before you have initialized it.

GetHead(list)
Compatible: Yes
Location: exec/lists.h

Returns a pointer to the first node of a list or NULL if the list is empty.

GetTail(list)
Compatible: Yes
Location: exec/lists.h

Returns a pointer to the last node of a list or NULL if the list is empty.

GetSucc(node)
Compatible: Yes
Location: exec/lists.h

Returns a pointer to the next node of a list or NULL if there is none.

GetPred(list)
Compatible: Yes
Location: exec/lists.h

Returns a pointer to the previous node of a list or NULL if there is none.

ForeachNode(list,node)
Compatible: Yes
Location: exec/lists.h

Iterates through a list. A block of code must follow this macro. The block doesn't get executed if the list is empty. When the list terminates node doesn't contain NULL but node->ln_Succ will be NULL. You cannot use this macro if you want to delete the nodes in the list (ie. you must not call Remove() inside the block of code following the macro).

INTUITIONNAME
Compatible: Yes
Location: intuition/intuition.h

Contains the name of the Intuition library. You should use this in OpenLibrary(), for example, to avoid typos.

5.3.2 Resource Tracking (RT) *Updated*

Everyone talks about RT but what's it anyway ? RT means three things:

  1. The OS takes notes about allocated resources (eg. memory, windows, libraries, devices, screens, etc).

  2. The OS checks the usage of those resources (ie. Did you open that window you want to render into ? Is it still open ? Is that a window anyway ?)

  3. The OS closes resources if they are no longer used (either because your program crashed or because it exited without freeing them).

The current implementation can do all three things but to enable it, you must make some modifications to your code. The only disadvantage of the current implementation is that the resources won't be freed if the program crashes.

  1. Add the following lines to your code. It should be the first thing seen by the compiler:

    If you replace the 1 by 0, then RT will be silently disabled.

  2. Add #include <aros/rt.h> after the last include from proto/

  3. Add RT_Init(); as the first command in main().

  4. Call RT_Exit() before you terminate your program.

  5. Recompile.

The advantages are that you will get errors if you try to access resources which you didn't allocate and that you will get a list of resources which you didn't free at the end of your program. All messages will contain the position in the code where the error happened (if available) and the position in the code where the resource was allocated (this is the reason why RT has to be compiled in. It could be built into the OS, too, but it would be hard to gather the information where an error occurred).

A good example about how to use RT and what it can do can be found in AROS/workbench/demos/rtdemo.c( Output of rtdemo).

The following resources are tracked:


prev up next

If you have comments or suggestions, email me at digulla@aros.fh-konstanz.de. 13. Aug 1997